<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>分配角色</title>
</head>
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/jquery-3.5.1.js"></script>
<script type="text/javascript">
	$(function(){
		allRole();
		currentRole();
	});
	function allRole(){
		$.ajax({
			type:"post",
			url:"",
			data:"${param(id)}",
			success:function(result){
				var content="";
				$.each(result,function(i,n){
					content+="<option>"+n.roleId+n.roleName+"<option>";
				});
				$("#rightRoleBtn").html(content);
			}
		});
	}
	function currentRole(){
		$.ajax({
			type:"post",
			url:"",
			data:"${param(id)}",
			success:function(result){
				var content="";
				$.each(result,function(i,n){
					content+="<option>"+n.roleId+n.roleName+"<option>";
				});
				$("#rightRoleBtn").html(content);
			}
		});
	}
	
	$("#rightRoleBtn").click(function(){
		$("#rightRoleList").append($("#leftRoleList option:selected"),clone());
		$("#leftRoleList option:selected").remove();
		$.ajax({
			type:"post",
			url:"",
			data:"${param(id)}",
			success:function(result){
				var content="";
				$.each(result,function(i,n){
					content+="<option>"+n.roleId+n.roleName+"<option>";
				});
				$("#rightRoleBtn").html(content);
			}
		});
	});
	$("#leftRoleList").click(function(){
		$("#leftRoleList").append($("#rightRoleList option:selected"),clone());
		$("#rightRoleList option:selected").remove();
	});
</script>
<body>
	<div id="leftRoleList">
		<!-- 查询所有角色放这里 -->
	</div>
	<button type="button" id="rightRoleBtn">></button>
	<button type="button" id="leftRoleBtn">$amp;</button>
	<div id="rightRoleList">
		<!-- 查询当前页面的用户所拥有的角色放这里 -->
	</div>
</body>
</html>